package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Category;
import com.sky.result.Result;
import com.sky.vo.CategorySelectIdVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author L9629
 */
@Mapper
public interface CategoryMapper {
    Page<Category> selectPageCategory(CategoryPageQueryDTO dto);
    @AutoFill(OperationType.UPDATE)
    int reviseCategory(Category category);
    @AutoFill(OperationType.UPDATE)
    void reviseStatus(Category category);
     @AutoFill(OperationType.INSERT)
    void insertCategory(Category newCategory);

    /**
     * 根据分类名称查询数据库 是否存在
     */
    Category selectByName(String name);

    List<CategorySelectIdVO> selectTypeId(Integer type);
    @Delete("delete from category where id=#{id}")
    int deleteById(Integer id);
    @Select("select * from category where id=#{id}")
    Category selectById(Long id);
}
